package com.wd.cloud.applet.controller.manage;

import com.wd.cloud.applet.common.Response;
import com.wd.cloud.applet.common.exception.CustomException;
import com.wd.cloud.applet.config.CustomListResultConfig;
import com.wd.cloud.applet.entity.bo.SysMenuInfoBO.SysMenuInfoListBO;
import com.wd.cloud.applet.entity.bo.SysMenuInfoBO.SysMenuInfoSaveBO;
import com.wd.cloud.applet.entity.commons.RequestPrimaryKeyModel;
import com.wd.cloud.applet.entity.vo.SysMenuInfoVO.SysMenuInfoByListVO;
import com.wd.cloud.applet.entity.vo.SysMenuInfoVO.SysMenuInfoListVO;
import com.wd.cloud.applet.entity.vo.SysMenuInfoVO.SysMenuInfoKeyVO;
import com.wd.cloud.applet.entity.vo.SysMenuInfoVO.SysMenuInfoPageListVO;
import com.wd.cloud.applet.entity.vo.SysMenuInfoVO.SysMenuRoleListVO;
import com.wd.cloud.applet.service.ISysMenuInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * 菜单表控制器
 * Created on 2023年04月23日
 * @author  <a href="mailto: 987707681@qq.com">hjx</a>
 * @version 1.0
 * Copyright (c) 2023年 代码生成器
 */
@Api(tags = "菜单表控制器")
@RestController
@RequestMapping("api/manage/sysMenuInfo")
public class SysMenuInfoController {
    @Resource
    private ISysMenuInfoService sysMenuInfoService;

    /**
     * 新增/编辑
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "新增/编辑")
    @PostMapping("/save")
    public Response save(@RequestBody SysMenuInfoSaveBO dto) {
        if (sysMenuInfoService.save(dto) > 0) {
            return Response.ok();
        } else {
            throw new CustomException("操作失败", 101);
        }
    }

    /**
     * 删除操作
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "删除操作")
    @PostMapping("/delByIdentify")
    public Response delByIdentify(@RequestBody RequestPrimaryKeyModel dto) {
        if (sysMenuInfoService.deleteByPrimaryKey(dto) > 0) {
            return Response.ok("删除成功");
        } else {
            throw new CustomException("操作失败", 101);
        }
    }

    /**
     * 获取分页列表数据
     *
     * @param params
     * @return
     */
    @ApiOperation(value = "获取分页列表数据")
    @PostMapping("/getListPage")
    public Response<CustomListResultConfig<SysMenuInfoListVO>> getListPage(
        @RequestBody SysMenuInfoListBO params) {
        CustomListResultConfig<SysMenuInfoListVO> selectByPageList =
            sysMenuInfoService.selectByPageList(params);
        return Response.ok(selectByPageList);
    }
    /**
     * 获取菜单列表信息
     *
     * @return
     */
    @ApiOperation(value = "获取菜单列表信息")
    @PostMapping("/getMenuList")
    public Response<List<SysMenuInfoByListVO>> getMenuList() {
        List<SysMenuInfoByListVO> selectByPageList = sysMenuInfoService.getMenuList();
        return Response.ok(selectByPageList);
    }
    /**
     * 获取分页列表数据
     *
     * @return
     */
    @ApiOperation(value = "获取分页列表数据")
    @PostMapping("/getList")
    public Response<List<SysMenuInfoPageListVO>> getList() {
        List<SysMenuInfoPageListVO> selectByPageList = sysMenuInfoService.selectByList();
        return Response.ok(selectByPageList);
    }
    /**
     * 根据ID获取实体数据
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "根据ID获取实体数据")
    @PostMapping("/getEntityByKey")
    public Response<SysMenuInfoKeyVO> getEntityByKey(@RequestBody RequestPrimaryKeyModel dto) {
        SysMenuInfoKeyVO model = sysMenuInfoService.selectByPrimaryKey(dto);
        return Response.ok(model);
    }
    /**
     * 读取菜单列表
     *
     * @param dto
     * @return
     */
    @ApiOperation(value = "读取菜单列表")
    @PostMapping("/menuRoleList")
    public Response<SysMenuRoleListVO> menuRoleList(@RequestBody RequestPrimaryKeyModel dto) {
        SysMenuRoleListVO model = sysMenuInfoService.menuRoleList(dto);
        return Response.ok(model);
    }
}
